<template>
  <div>
    <div class="banner">
      <div class="img-wrapper"
        @click="showGallery">
        <img class="img" :src="bannerImg" alt="">
      </div>
      <div class="icon-swipe">
        <span class="icon-photo iconfont">&#xe604;</span>
        {{ galleryImgs.length }}
      </div>
      <div class="title">{{ sightName }}</div>
    </div>
    <fade-animation>
      <common-gallery v-show="showFlag"
        :galleryImgs="galleryImgs"
        @hideGallery="hideGallery">
      </common-gallery>
    </fade-animation>
  </div>
</template>

<script>
import FadeAnimation from './FadeAnimation'
import CommonGallery from './CommonGallery'

export default {
  name: 'DetailBanner',
  components: {
    FadeAnimation,
    CommonGallery
  },
  props: {
    sightName: String,
    bannerImg: String,
    galleryImgs: Array
  },
  data () {
    return {
      showFlag: false
    }
  },
  methods: {
    showGallery () {
      this.showFlag = true
    },
    hideGallery () {
      this.showFlag = false
    }
  }
}
</script>

<style lang="stylus" scoped>
  .banner
    position relative
    .img-wrapper
      width 100%
      height 0
      padding-bottom 55%
      .img
        width 100%
    .icon-swipe
      position absolute
      left .2rem
      right .2rem
      bottom .86rem
      width 1.2rem
      line-height .4rem
      text-align center
      font-size .24rem
      background rgba(0, 0, 0, .5)
      border-radius .2rem
      color #fff
      .icon-photo
        font-size .24rem
    &:after
      content ""
      display block
      position absolute
      bottom 0
      left 0
      width 100%
      min-height .6rem
      background-color transparent
      background-image linear-gradient(to bottom,rgba(0,0,0,0),rgba(0,0,0,.8))
    .title
      position absolute
      left .2rem
      right .2rem
      bottom .36rem
      line-height .4rem
      font-size .36rem
      color #fff
</style>
